# Read in the data:
oilspill <- read_sf(here("oil_spill_data"),
                    layer = "Oil_Spill_Incident_Tracking_%5Bds394%5D") %>% 
  clean_names() %>% 
  mutate(date = as.Date(dateofinci)) %>% 
  mutate(date = ymd(date)) %>% 
  rename(name = localecoun) %>% 
  select(name, date, inlandmari)

counties <- read_sf(here("ca_counties"),
                    layer = "CA_Counties_TIGER2016") %>% 
  clean_names() %>% 
  select(name)
tmap_mode("view")

tm_shape(counties)+
  tm_polygons(alpha = 0.4)+
  tm_shape(oilspill)+
  tm_dots(col = "red", scale = .8, alpha = 0.6)+
  tm_basemap("Esri.WorldTopoMap")
oil_counties <- counties %>% 
  st_join(oilspill) %>% 
  count(name.x, inlandmari) %>% 
  filter(inlandmari == "Inland")
ggplot(data = oil_counties)+
  geom_sf(aes(fill = n))+
  scale_fill_viridis(option = "plasma")+
  theme_void()